package com.etc.homework;

import java.util.HashSet;

/**
 * @author: knowno
 * @create: 2024-09-11 09:01
 * @Version 1.0
 **/
public class TestEmployee {

    public static void main(String[] args) {

        HashSet<Employee> hashSet = new HashSet<>();
        Employee employee1 = new Employee("20240001", "张三", "软件开发工程师", 12345);
        Employee employee2 = new Employee("20240002", "留六", "硬件开发工程师", 12345);
        Employee employee3 = new Employee("20240003", "王其", "软件测试工程师", 12345);
        Employee employee4 = new Employee("20240003", "王其", "软件开发工程师", 12345);
        Employee employee5 = new Employee("20240001", "张三", "软件开发工程师", 12345);

        //因为我们重写了hashcode和equals方法，因此，这里大家看到的add方法中，如果有empno和name都相同，那么我们的hashset就认为这是相同的对象
        hashSet.add(employee1);
        hashSet.add(employee2);
        hashSet.add(employee3);
        hashSet.add(employee4);
        hashSet.add(employee5);
        System.out.println(hashSet.size());

    }
}
